<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <title>首页</title>
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script th:src="@{/static/js/jquery.min.js}"></script>
    <style type="text/css">
        table {border-collapse: collapse; font-size: 14px; width: 80%; margin: auto}
        table, th, td {border: 1px solid darkslategray;padding: 10px}
    </style>
    <style type="text/css">
        html,body {
            background: linear-gradient(to bottom, #fff1eb 0%, #ace0f9 100%);
            width: 100%;
            height: 100%;
        }
    </style>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@5.3.2/dist/echarts.min.js"></script>
</head>
<body>
<div style="text-align: center">
    <span style="color: darkslategray; font-size: 30px"></span>

    <div style="margin: 20px 100px 40px 0;font-size: 18px;text-align: right;">
        <strong>欢迎<span th:text="${user.username}"></span>登录系统</strong>
    </div>

    <div style="text-align: left;overflow:hidden;margin-bottom: 30px;">
        <div style="float: right; margin-right: 200px;">
            <form th:action="add" method="get">
                <input type="hidden" name="userID" th:value="${user.id}">
                <a th:href="@{'/query-store' +  '?token=' + ${user.token} }">返回仓库列表</a>
            </form>
        </div>
    </div>


    <div style="text-align: left;overflow:hidden;margin-bottom: 30px;">
        最优路径为：<span th:text="${s}"></span>
        <br>
        <div id="container" style="height: 500px"></div>
    </div>





</div>
<script type="text/javascript">
    var dom = document.getElementById("container");
    var myChart = echarts.init(dom);
    var app = {};

    var option;



    const symbolSize = 20;
    var data = [];

    $.ajax({url:"/dispatch/get-tabu",async:false,success:function (res) {
        let path = res.data.data;
        data = path;

    }})

    option = {
        title: {
            text: '如果没有交点则为最优路线'
        },
        tooltip: {
            formatter: function (params) {
                var data = params.data || [0, 0];
                return data[0].toFixed(2) + ', ' + data[1].toFixed(2);
            }
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: {
            min: 0,
            max: 100,
            type: 'value',
            axisLine: { onZero: false }
        },
        yAxis: {
            min: 0,
            max: 100,
            type: 'value',
            axisLine: { onZero: false }
        },
        series: [
            {
                id: 'a',
                type: 'line',
                smooth: true,
                symbolSize: symbolSize,
                data: data
            }
        ]
    };
    var zr = myChart.getZr();

    zr.on('mousemove', function (params) {
        var pointInPixel = [params.offsetX, params.offsetY];
        zr.setCursorStyle(
            myChart.containPixel('grid', pointInPixel) ? 'copy' : 'default'
        );
    });

    if (option && typeof option === 'object') {
        myChart.setOption(option);
    }

</script>
</body>
</html>
